using System;
using System.Collections.Generic;
using Enume;
using Struct;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;

namespace SO {



    public class BaseTriggerItemSO : ScriptableObject {



        [Header("ID")]
        public int itemId;

        [Header("名称")]
        public string itemName;

        public string GetItemName() {
            return itemName.AddColor(itemColor);
        }
        public Color itemColor;

        [PreviewField(100)]
        [Header("图标")]
        public Sprite itemIcon;

        [Header("描述")]
        [TextArea(3, 10)]
        public string itemDesc;

        public string GetItemDesc() {
            string colorDesc = itemDesc.Replace("↑", "<color=#00FF00FF>↑</color>").Replace("↓", "<color=#FF0000FF>↓</color>");
            return colorDesc;
        }

        [Header("最大等级/最大数量")]
        public int itemMaxLevel;


        [Header("检查时机")]
        [EnumToggleButtons]
        public EnumItemCheckTiming itemCheckTiming;

        [Header("附加属性")]
        public List<PropertiesStruct> itemAdditionalAttributes = new();

        [EnumToggleButtons]
        public EnumItemQuality itemQuality;

        public string GetItemQualityColorText() {
            string str = String.Empty;
            string strColor = String.Empty;
            switch (itemQuality) {
                case EnumItemQuality.Normal:
                    str = "普通";
                    strColor = "dfe4ea";
                    break;
                case EnumItemQuality.Legend:
                    str = "传奇";
                    strColor = "4EC2FFFF";
                    break;
                case EnumItemQuality.Mythic:
                    str = "神话";
                    strColor = "FF0000FF";
                    break;
            }

            return str.AddColor(strColor);
        }


        [Header("触发条件")]
        public List<ItemTriggerCondition> itemTriggerConditions;


        [Header("触发效果")]
        public List<ItemTrigerEffect> itemTriggerEffects;


    }
    

    

    /// <summary>
    /// 技能触发条件
    /// </summary>
    [Serializable]
    public class ItemTriggerCondition {

        [Tooltip("运算条件 = 判断条件一 相对于 判断条件二 的运算符")]
        [Header("判断条件1")]
        public EnumPropertiesType propertyType_1;

        [Header("条件运算符")]
        [EnumToggleButtons]
        public EnumMathematicalJudgmentType mathematicalJudgmentType;

        [Header("条件值")]
        public float triggerValue;
        [Header("百分比")]
        public bool isPercentage;
        [Header("判断条件2")]
        public EnumPropertiesType propertyType_2;

    }

    /// <summary>
    /// 技能触发条件
    /// </summary>
    [Serializable]
    public class ItemAdditionalProperties {

        [Tooltip("运算条件 = 判断条件一 相对于 判断条件二 的运算符")]
        [Header("具体增加的属性")]
        public EnumPropertiesType addPropertiesType;

        [Header("条件运算符")]
        [EnumToggleButtons]
        public EnumMathematicalOperatorsType mathematicalOperatorsType;

        [Header("条件值")]
        public int triggerValue;

        [Header("是否启用随机")]
        public bool isRandom;
        [Header("随机最小值")]
        public int randomValueMix;
        [Header("随机最大值")]
        public int randomValueMax;

        [Header("值乘技能等级")]
        public bool isValueMultiplyLevel;
        [Header("百分比")]
        public bool isPercentage;
        [Header("值的来源")]
        public EnumPropertiesType conditionPropertiesType;



    }


    /// <summary>
    /// 技能触发效果
    /// </summary>
    [Serializable]
    public class ItemTrigerEffect {
        [Header("技能生效目标类型")]
        [EnumToggleButtons]
        public EnumItemTargetType itemTargetType;

        [Header("技能生效目标数量")]
        public int itemTargetCount;

        [Header("额外附加的属性值")]
        public List<ItemAdditionalProperties> itemAdditionalPropertiesList;

        [Header("额外添加的Buff")]
        public List<ItemTriggerBuff> itemTriggerBuffs;



    }

    [Serializable]
    public class ItemTriggerBuff {
        // public string buffName;

        [Header("buff持续回合")]
        public int rounds;

        [Header("回合数是否同等级增加")]
        public bool isValueMultiplyLevel;

        [Header("额外附加的属性值")]
        public List<ItemAdditionalProperties> itemAdditionalPropertiesList;

        [Header("buff类型")]
        public List<EnumBuffType> effectBuffType;


    }



}